package CharacterDevelop;

/**
 * ClassName:StringTest012
 * Package:CharacterDevelop
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/16-15:49
 * @Version:v1.0
 */
public class StringTest012 {
    public static void main(String[] args) {
        //敏感词替换  String replace(旧值，新值) 替换
        //只有返回值才是替换之后的效果
        //获取到发言
        String talk = "你玩的真好,以后不要再玩了,TMD";
        //定义一个敏感词库
        String[]arr={"TMD","CNM","SB","MLGB"};
        //循环得到数组中的每一个敏感词,依次进行替换
        for (int i = 0; i < arr.length; i++) {
            talk = talk.replace(arr[i],"*****");
        }
//        String result = talk.replace("TMD", "****");
        System.out.println(talk);

    }
}
